home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 2.0 KB | 84 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWODThrd.h
- // Release Version: $ ODF 2 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- // Utility classes for threads. Allocate a SOM Environment and handle
- // exceptions.
- //
- //========================================================================================
-
- #ifndef _FW_ODThrd_
- #define _FW_ODThrd_
-
- #include "SLODThrd.h"
-
- #include <Threads.h>
- #include <Timer.h>
-
- struct FW_SWakeupTask;
-
- extern const FW_PlatformError FW_xThreadKilled;
-
- //-----------------------------------------------------------------------------
- // FW_CThread
- // Wrapper for threads, allocates a SOM Environment and catches exceptions.
- //-----------------------------------------------------------------------------
-
- typedef ThreadID FW_PlatformThread;
-
- class FW_CThread {
- public:
- FW_CThread (void* parameters = kODNULL, FW_ThreadProcedure procedure = kODNULL);
- ~FW_CThread ();
-
- //
- // Public Interface
- //
- void Sleep (long ticks);
- void Suspend ();
- void Resume ();
-
- protected:
- //
- // Customizable Behavior
- //
- virtual void Run (Environment* ev);
- // virtual void Switch (FW_Boolean switchingOut);
-
- protected:
- //
- // Implementation
- //
- void PrivKill (FW_Boolean beNiceAboutIt);
- #ifdef FW_BUILD_MAC
- // Thread Callbacks
- static pascal void* PrivMacEnter (void* selfThread);
- static pascal void PrivMacSwitchIn (ThreadID threadBeingSwitched, void* selfThread);
- static pascal void PrivMacSwitchOut (ThreadID threadBeingSwitched, void* selfThread);
- static pascal void PrivMacTerminate (ThreadID threadTerminated, void* selfThread);
- // Sleeping
- static pascal void PrivMacWakeup (TMTaskPtr tmTaskPtr);
- static RoutineDescriptor gMacWakeupInfo;
- #else
- #error stop
- #endif
- private:
- //
- // Data
- //
- FW_PlatformThread fPlatformThread;
- void* fParameters;
- FW_ThreadProcedure fProcedure;
- #ifdef FW_BUILD_MAC
- void* fResult;
- #endif
- // Sleeping
- FW_SWakeupTask* fWakeupTask;
- };
-
- #endif // _FW_ODThrd_
-
-